<template>
    <div>
        <div>
            姓名:
            <input type="text" v-model="info.name">
            职业:
             <select v-model="info.roleid">
                        <option value="">请选择</option>
                        <option :value="item.roleId" v-for="item in getselect">{{ item.roleName }}</option>
                        </select>
            <input type="button" value="查询" class="btn btn-primary" @click="show">
        </div>
        <h1>显示会员</h1>
        <table class="table table-bordered">
            <tbody>
               <tr>
                <td>姓名</td>
                <td>性别</td>
                <td>出生日期</td>
                <td>证件类型</td>
                <td>证件号码</td>
                <td>手机号</td>
                <td>职业</td>
                <td>状态</td>
                <td>详细地址</td>
               </tr>
                <tr :key="item.id" v-for="item in list" >
                <td>{{item.memberName}}</td>
                <td>{{item.memberSex==1?"男":"女"}}</td>
                <td>{{moment(item.memberTime).format("YYYY-MM-DD")}}</td>
                <td>{{item.memberType}}</td>
                <td>{{item.memberCard}}</td>
                <td>{{item.memberPhone}}</td>
                <td>{{item.roleName}}</td>
                <td>{{item.memberState==true?"启用":"禁用"}}</td>
                <td>{{item.memberAddress}}</td>
               </tr>
            </tbody>
        </table>
    </div>
</template>

<script setup lang="ts">
import {ref,reactive,onMounted} from "vue";
import moment from "moment"
import axios from 'axios'
import {useRouter,useRoute} from "vue-router";
onMounted(()=>
{
    getseletes();
    show();
})
const router=useRouter();
const route=useRoute();

let getselect:any=ref([]);
const getseletes=()=>
{
    axios({
        url:'http://localhost:5235/api/Member/GetRoles',
        method:"get",
    })
    .then((res)=>
    {
        console.log(res);
        getselect.value=res.data;
    })
    .catch((err)=>
    {
        console.log(err);
    })
}
let info:any=reactive({
        name:"",
        roleid:"",
})
let list:any=ref([]);
const show=()=>
{
    
    axios({
        url:'http://localhost:5235/api/Member/Show',
        method:"get",
        params:info
    })
    .then((res)=>
    {
        console.log(res);
        list.value=res.data;
    })
    .catch((err)=>
    {
        console.log(err);
    })
}

</script>

<style scoped>

</style>